/**
 * Created by Administrator on 2016/3/25.
 */
$(function(){
    $(".gContainer img").mousedown(function(){
        $(this).attr("src","images/gWant1.png");
    });
    $(".gContainer img").mouseup(function(){
        $(this).attr("src","images/gWant.png");
    });


    $(".gwant").click(function(){
    	$.ajax({
            url: "../sys/heart.do",
            async: false,
            type : "post",
            dataType : "json",
            success:function(d){
            	if(d.success){
            		$(".register,.center").show();
                }
                else{
                	alert("请先登录后再报名");
                	window.location.href = 'login.html?redirectUrl=gActivedetail.html';
            	}
            }
        });
    })
    $(".center img").click(function(){
        $(".register,.center").hide();
    })
    $(".center img").mousedown(function(){
        $(this).attr("src","images/gdetailclose2.png");
    })
    $(".center img").mouseup(function(){
        $(this).attr("src","images/gdetailclose1.png");
    })

    $(".center div").mousedown(function(){
        $(this).css("background","#0b427f");
    })
    $(".center div").mouseup(function(){
        $(this).css("background","#f00");

        $.ajax({
            method:"POST",
            url:"../activity/cancelActivity.do",
            data:{
                uid:uid,
                aid:aid
            },
            dataType:"JSON",
            success:function(data){
                if(data.success){
                    alert("报名成功");
                }else{
                    alert("报名失败");
                }
            }

        })
    })
});